home *** CD-ROM | disk | FTP | other *** search
- // MainFrm.cpp : implementation of the CMainFrame class
- //
-
- #include "stdafx.h"
- #include "SlsDemo.h"
-
- #include "MainFrm.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- #define ID_TIMER_UPDATE 0x10
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
-
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
-
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_WM_DESTROY()
- ON_WM_TIMER()
- ON_UPDATE_COMMAND_UI(ID_FEATURE_FEATURELEVEL1, OnUpdateFeatureFeaturelevel1)
- ON_UPDATE_COMMAND_UI(ID_FEATURE_FEATURELEVEL2, OnUpdateFeatureFeaturelevel2)
- ON_UPDATE_COMMAND_UI(ID_FEATURE_FEATURELEVEL3, OnUpdateFeatureFeaturelevel3)
- ON_UPDATE_COMMAND_UI(ID_FEATURE_FEATURELEVEL4, OnUpdateFeatureFeaturelevel4)
- ON_UPDATE_COMMAND_UI(ID_FEATURE_FEATURELEVEL5, OnUpdateFeatureFeaturelevel5)
- //}}AFX_MSG_MAP
- // Global help commands
- ON_COMMAND(ID_HELP_FINDER, CFrameWnd::OnHelpFinder)
- ON_COMMAND(ID_HELP, CFrameWnd::OnHelp)
- ON_COMMAND(ID_CONTEXT_HELP, CFrameWnd::OnContextHelp)
- ON_COMMAND(ID_DEFAULT_HELP, CFrameWnd::OnHelpFinder)
- END_MESSAGE_MAP()
-
- static UINT indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
-
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
-
- CMainFrame::CMainFrame()
- {
- // TODO: add member initialization code here
-
- }
-
- CMainFrame::~CMainFrame()
- {
- }
-
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- if (!m_wndToolBar.Create(this) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbar\n");
- return -1; // fail to create
- }
-
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status bar\n");
- return -1; // fail to create
- }
-
- // TODO: Remove this if you don't want tool tips or a resizeable toolbar
- m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
- CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
-
- // TODO: Delete these three lines if you don't want the toolbar to
- // be dockable
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndToolBar);
-
- m_nUpdateTimerID=SetTimer(ID_TIMER_UPDATE,60000,NULL);
- return 0;
- }
-
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
-
- return CFrameWnd::PreCreateWindow(cs);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
-
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CFrameWnd::AssertValid();
- }
-
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CFrameWnd::Dump(dc);
- }
-
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
-
- void CMainFrame::OnDestroy()
- {
- CFrameWnd::OnDestroy();
-
- KillTimer(m_nUpdateTimerID);
-
- }
-
- void CMainFrame::OnTimer(UINT nIDEvent)
- {
- if(nIDEvent==ID_TIMER_UPDATE)
- {
- CSlsDemoApp *pApp=(CSlsDemoApp *)AfxGetApp();
- SLS_UPDATE Update;
- SLS_PERMIT Permit;
- memset(&Update,0,sizeof(Update));
- if(!pApp->m_pSheriff->Update(Update,Permit))
- {
- pApp->m_bLicenceOK=FALSE;
- }
- }
-
- CFrameWnd::OnTimer(nIDEvent);
- }
-
- void CMainFrame::OnUpdateFeatureFeaturelevel1(CCmdUI* pCmdUI)
- {
- CSlsDemoApp *pApp=(CSlsDemoApp *)AfxGetApp();
- pCmdUI->Enable(pApp->m_bLicenceOK && pApp->m_nAccessKey>=1);
- }
-
- void CMainFrame::OnUpdateFeatureFeaturelevel2(CCmdUI* pCmdUI)
- {
- CSlsDemoApp *pApp=(CSlsDemoApp *)AfxGetApp();
- pCmdUI->Enable(pApp->m_bLicenceOK && pApp->m_nAccessKey>=2);
- }
-
- void CMainFrame::OnUpdateFeatureFeaturelevel3(CCmdUI* pCmdUI)
- {
- CSlsDemoApp *pApp=(CSlsDemoApp *)AfxGetApp();
- pCmdUI->Enable(pApp->m_bLicenceOK && pApp->m_nAccessKey>=3);
- }
-
- void CMainFrame::OnUpdateFeatureFeaturelevel4(CCmdUI* pCmdUI)
- {
- CSlsDemoApp *pApp=(CSlsDemoApp *)AfxGetApp();
- pCmdUI->Enable(pApp->m_bLicenceOK && pApp->m_nAccessKey>=4);
- }
-
- void CMainFrame::OnUpdateFeatureFeaturelevel5(CCmdUI* pCmdUI)
- {
- CSlsDemoApp *pApp=(CSlsDemoApp *)AfxGetApp();
- pCmdUI->Enable(pApp->m_bLicenceOK && pApp->m_nAccessKey>=5);
- }
-